package javadiary;

/**
 * 记录和操作日记信息
 *
 * @author Silence
 * @date 2022年 06月15日 12:42:53
 */
	import java.text.DateFormat;
 	import java.text.SimpleDateFormat;
 	import java.util.ArrayList;
 	import java.util.Date;
 	import java.util.Scanner;

public class DiaryOrder {
    static ArrayList<Diary> diarysList=new ArrayList<Diary>();
      public static void main(String[] args) throws Exception {
         			System.out.println("--------欢迎来到黑马日记本--------");
         			boolean falg = true;
         			Scanner scan=new Scanner(System.in);
         			while(falg) {
             				System.out.println("1.编写日记");
             				System.out.println("2.查看日记");
						    System.out.println("3.退出");
             				int a = scan.nextInt();
							 switch (a){
								 case 1:
									 System.out.println("请输入姓名：");
									 String name=scan.next();
									 System.out.println("请输入天气：");
									 String weather=scan.next();
									 System.out.println("请输入标题：");
									 String title=scan.next();
									 System.out.println("请输入内容：");
									 String content=scan.next();
									 Diary diary = addDiary(name,weather,title,content);
									 FileUtil.saveBooks(diary);break;
								 case 2:
									 FileUtil.readFile();break;
								 case 3:
									 System.out.println("感谢使用！");
									 System.exit(0);break;
								 default:System.out.println("输入错误");break;
							 }
             			}
         		}
          		private static Diary addDiary(String name,String weather,String title,String content) {
        			Date date = new Date();
        			DateFormat format = new SimpleDateFormat("yyyyMMdd");
        			String a=format.format(date).toString();
        			Diary diary=new Diary(a,name,weather,title,content);
        			return diary;
        		}

}
